package com.nanrui.mutualinductor.ui.service;


import com.nanrui.mutualinductor.communicate.PacketCallback;
import com.nanrui.mutualinductor.data.Packet_56_03;
import com.nanrui.mutualinductor.domains.FhwtRegulationTransformerViewInfo;
import com.nanrui.mutualinductor.ui.page.DKActivity;

//CT负荷外推法误差测试Service
public class FhwtRegulationTransformerService {
    private DKActivity activity;

    public FhwtRegulationTransformerService(DKActivity paramDKActivity) {
        this.activity = paramDKActivity;
    }

    /**
     * 显示数据
     *
     * @param fhwtRegulationTransformerViewInfo
     * @param paramPacket_56_03
     */
    public void display(FhwtRegulationTransformerViewInfo fhwtRegulationTransformerViewInfo, Packet_56_03 paramPacket_56_03) {
        //f u & r
        fhwtRegulationTransformerViewInfo.setsPhaseError(Float.valueOf(paramPacket_56_03.getsPhaseError()));
        fhwtRegulationTransformerViewInfo.setsQuadratureError(Float.valueOf(paramPacket_56_03.getsQuadratureError()));
        fhwtRegulationTransformerViewInfo.setsWorkingVoltage(Float.valueOf(paramPacket_56_03.getsWorkingVoltage()));
        fhwtRegulationTransformerViewInfo.setsSecondaryR(Float.valueOf(paramPacket_56_03.getsSecondaryR()));
        //表格数据
        fhwtRegulationTransformerViewInfo.setsIErrors(paramPacket_56_03.getsIErrors());
        fhwtRegulationTransformerViewInfo.setsIRoundErrors(paramPacket_56_03.getsIRoundErrors());
        fhwtRegulationTransformerViewInfo.setsPhaseDisps(paramPacket_56_03.getsPhaseDisps());
        fhwtRegulationTransformerViewInfo.setsPhaseRoundDisps(paramPacket_56_03.getsPhaseRoundDisps());

    }

    public FhwtRegulationTransformerViewInfo getDefaultViewInfo() {
        FhwtRegulationTransformerViewInfo localCurrentTransformerViewInfo = new FhwtRegulationTransformerViewInfo();
        localCurrentTransformerViewInfo.setmStatus((short) 1);
//        localCurrentTransformerViewInfo.setmRatedSecondary(5.0F);
//        localCurrentTransformerViewInfo.setmRatedPrimary(75.0F);
//        localCurrentTransformerViewInfo.setmGrade((short) 1);
//        localCurrentTransformerViewInfo.setmPhaseAngle(0.8F);
//        localCurrentTransformerViewInfo.setmRatedLoad(5.0F);
//        localCurrentTransformerViewInfo.setmMiniLoad(2.5F);
        return localCurrentTransformerViewInfo;
    }

    public void queryData(FhwtRegulationTransformerViewInfo fhwtRegulationTransformerViewInfo, PacketCallback<Packet_56_03> paramPacketCallback) {
        Packet_56_03 localPacket_56_03= new Packet_56_03();
        localPacket_56_03.setmFlag((short) 3);
        localPacket_56_03.setFrameNo((short) 03);
        localPacket_56_03.setmGrade(fhwtRegulationTransformerViewInfo.getmGrade());
        localPacket_56_03.setmRatedPrimary(fhwtRegulationTransformerViewInfo.getmRatedPrimary());
        localPacket_56_03.setmRatedSecondary(fhwtRegulationTransformerViewInfo.getmRatedSecondary());
        localPacket_56_03.setmRatedLoad(fhwtRegulationTransformerViewInfo.getmRatedLoad());
        localPacket_56_03.setmMiniLoad(fhwtRegulationTransformerViewInfo.getmMiniLoad());
        localPacket_56_03.setmPhaseAngle(fhwtRegulationTransformerViewInfo.getmPhaseAngle());
        this.activity.sendPacket(localPacket_56_03, paramPacketCallback);
    }

    public void resetResult(FhwtRegulationTransformerViewInfo fhwtRegulationTransformerViewInfo) {
        fhwtRegulationTransformerViewInfo.setsPhaseError(null);
        fhwtRegulationTransformerViewInfo.setsQuadratureError(null);
        fhwtRegulationTransformerViewInfo.setsWorkingVoltage(null);
        fhwtRegulationTransformerViewInfo.setsSecondaryR(null);
        fhwtRegulationTransformerViewInfo.setsIErrors(null);
        fhwtRegulationTransformerViewInfo.setsIRoundErrors(null);
        fhwtRegulationTransformerViewInfo.setsPhaseDisps(null);
        fhwtRegulationTransformerViewInfo.setsPhaseRoundDisps(null);
        fhwtRegulationTransformerViewInfo.setsResult(null);
    }

//    public void save(CurrentTransformerViewInfo paramCurrentTransformerViewInfo)
//    {
//        CTErrorResp localCTErrorResp = new CTErrorResp();
//        localCTErrorResp.setsPhaseError(paramCurrentTransformerViewInfo.getsPhaseError());
//        localCTErrorResp.setsQuadratureError(paramCurrentTransformerViewInfo.getsQuadratureError());
//        localCTErrorResp.setsWorkingVoltage(paramCurrentTransformerViewInfo.getsWorkingVoltage());
//        localCTErrorResp.setsSecondaryR(paramCurrentTransformerViewInfo.getsSecondaryR());
//        localCTErrorResp.setsIErrors(paramCurrentTransformerViewInfo.getsIErrors());
//        localCTErrorResp.setsIRoundErrors(paramCurrentTransformerViewInfo.getsIRoundErrors());
//        localCTErrorResp.setsPhaseDisps(paramCurrentTransformerViewInfo.getsPhaseDisps());
//        localCTErrorResp.setsPhaseRoundDisps(paramCurrentTransformerViewInfo.getsPhaseRoundDisps());
//        localCTErrorResp.setsResult(paramCurrentTransformerViewInfo.getsResult().shortValue());
//        localCTErrorResp.setmRatedPrimary(paramCurrentTransformerViewInfo.getmRatedPrimary());
//        localCTErrorResp.setmRatedSecondary(paramCurrentTransformerViewInfo.getmRatedSecondary());
//        localCTErrorResp.setmGrade(paramCurrentTransformerViewInfo.getmGrade());
//        localCTErrorResp.setmCos(paramCurrentTransformerViewInfo.getmPhaseAngle());
//        localCTErrorResp.setmRatedLoad(paramCurrentTransformerViewInfo.getmRatedLoad());
//        localCTErrorResp.setmMiniLoad(paramCurrentTransformerViewInfo.getmMiniLoad());
//        localCTErrorResp.setmTemp(Float.valueOf(0.0F));
//        localCTErrorResp.setmRH(Float.valueOf(0.0F));
//        localCTErrorResp.setmCreateDate(System.currentTimeMillis());
//        return localCTErrorResp;
//    }

    public void startMeasure(FhwtRegulationTransformerViewInfo fhwtRegulationTransformerViewInfo, PacketCallback<Packet_56_03> paramPacketCallback) {
        Packet_56_03 localPacket_56_03 = new Packet_56_03();
        localPacket_56_03.setmFlag((short) 1);
        localPacket_56_03.setFrameNo((short) 03);
        localPacket_56_03.setmGrade(fhwtRegulationTransformerViewInfo.getmGrade());
        localPacket_56_03.setmRatedPrimary(fhwtRegulationTransformerViewInfo.getmRatedPrimary());
        localPacket_56_03.setmRatedSecondary(fhwtRegulationTransformerViewInfo.getmRatedSecondary());
        localPacket_56_03.setmRatedLoad(fhwtRegulationTransformerViewInfo.getmRatedLoad());
        localPacket_56_03.setmMiniLoad(fhwtRegulationTransformerViewInfo.getmMiniLoad());
        localPacket_56_03.setmPhaseAngle(fhwtRegulationTransformerViewInfo.getmPhaseAngle());
        this.activity.sendPacket(localPacket_56_03, paramPacketCallback);
    }

    public void stopMeasure(FhwtRegulationTransformerViewInfo fhwtRegulationTransformerViewInfo, PacketCallback<Packet_56_03> paramPacketCallback) {
        Packet_56_03 localPacket_56_03 = new Packet_56_03();
        localPacket_56_03.setmFlag((short) 4);
        localPacket_56_03.setFrameNo((short) 03);
        localPacket_56_03.setmGrade(fhwtRegulationTransformerViewInfo.getmGrade());
        localPacket_56_03.setmRatedPrimary(fhwtRegulationTransformerViewInfo.getmRatedPrimary());
        localPacket_56_03.setmRatedSecondary(fhwtRegulationTransformerViewInfo.getmRatedSecondary());
        localPacket_56_03.setmRatedLoad(fhwtRegulationTransformerViewInfo.getmRatedLoad());
        localPacket_56_03.setmMiniLoad(fhwtRegulationTransformerViewInfo.getmMiniLoad());
        localPacket_56_03.setmPhaseAngle(fhwtRegulationTransformerViewInfo.getmPhaseAngle());
        this.activity.sendPacket(localPacket_56_03, paramPacketCallback);
    }

    public void updateConfig(FhwtRegulationTransformerViewInfo fhwtRegulationTransformerViewInfo, PacketCallback<Packet_56_03> paramPacketCallback) {
        Packet_56_03 localPacket_56_03 = new Packet_56_03();
        localPacket_56_03.setmFlag((short) 0);
        localPacket_56_03.setFrameNo((short) 03);
        localPacket_56_03.setmGrade(fhwtRegulationTransformerViewInfo.getmGrade());
        localPacket_56_03.setmRatedPrimary(fhwtRegulationTransformerViewInfo.getmRatedPrimary());
        localPacket_56_03.setmRatedSecondary(fhwtRegulationTransformerViewInfo.getmRatedSecondary());
        localPacket_56_03.setmRatedLoad(fhwtRegulationTransformerViewInfo.getmRatedLoad());
        localPacket_56_03.setmMiniLoad(fhwtRegulationTransformerViewInfo.getmMiniLoad());
        localPacket_56_03.setmPhaseAngle(fhwtRegulationTransformerViewInfo.getmPhaseAngle());
        this.activity.sendPacket(localPacket_56_03, paramPacketCallback);
    }
}

